package dhz.tools.service;

import java.io.File;

/**
 * 打开目录实现类
 * @author dhz
 */
public class OpenDirService {

	/**
	 * 打开所在目录或目录
	 * @param file
	 * @throws Exception
	 */
	public void openDir(File file) throws Exception{
		String path = null;
		if(file.isFile()){
			path = file.getParent();
		}else if(file.isDirectory()){
			path = file.getAbsolutePath();
		}else{
			throw new Exception("指定的资源不存在！");
		}
		Runtime.getRuntime().exec(new String[]{"cmd","/c","start",path});
	}
}
